<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('提现记录列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label style="width: 100px;">提现方式：</label>
                            <select name="type" th:with="type=${@dict.getType('tx_mode')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 100px;">账号类型：</label>
                            <select name="accountType" th:with="type=${@dict.getType('tx_account_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 100px;">提现状态：</label>
                            <select name="status" th:with="type=${@dict.getType('tx_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label style="width: 105px;">申请提現时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="startTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="endTime"/>
                        </li>
                        <li>
                            <label style="width: 105px;">关键字查询字段：</label>
                            <select name="fields">
                                <option value="trueName" selected>姓名</option>
                                <option value="partnerTradeNo">订单号</option>
                                <option value="paymentNo">付款单号</option>
                            </select>
                            <input type="text" name="keywords"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:withdrawal:add">-->
            <!--<i class="fa fa-plus"></i> 添加-->
            <!--</a>-->
            <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()"-->
            <!--shiro:hasPermission="system:withdrawal:edit">-->
            <!--<i class="fa fa-edit"></i> 修改-->
            <!--</a>-->
            <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"-->
            <!--shiro:hasPermission="system:withdrawal:remove">-->
            <!--<i class="fa fa-remove"></i> 删除-->
            <!--</a>-->
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:withdrawal:export">-->
            <!--<i class="fa fa-download"></i> 导出-->
            <!--</a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:withdrawal:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:withdrawal:remove')}]];

    var refusePassFlag = [[${@permission.hasPermi('system:withdrawal:refusePass')}]];
    var adoptTxFlag = [[${@permission.hasPermi('system:withdrawal:adoptTx')}]];

    var typeDatas = [[${@dict.getType('tx_mode')}]];
    var accountTypeDatas = [[${@dict.getType('tx_account_type')}]];
    var statusDatas = [[${@dict.getType('tx_status')}]];
    var prefix = ctx + "system/withdrawal";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "提现记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '提现记录id',
                    visible: false
                },
                {
                    field: 'loginPhone',
                    title: '账号名'
                },
                {
                    field: 'trueName',
                    title: '姓名'
                }
                , {
                    field: 'accountName',
                    title: '账号类型'
                },
                {
                    field: 'type',
                    title: '提现方式',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'amount',
                    title: '实际到账'
                },
                {
                    field: 'applyAmount',
                    title: '申请提现金额'
                },
                {
                    field: 'poundage',
                    title: '提现手续费'
                },
                {
                    field: 'applyTime',
                    title: '申请时间'
                },
                {
                    field: 'accountType',
                    title: '账号类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(accountTypeDatas, value);
                    }
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    field: 'partnerTradeNo',
                    title: '订单号'
                },
                {
                    field: 'paymentNo',
                    title: '付款单号'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        // 状态1、未审核，2、已通过，3、提现成功，4、提现失败，5、已拒绝
                        if (row.status == 1) {
                            // 未审核，进行审核操作

                            // 拒绝审核
                            actions.push('<a class="btn btn-danger btn-xs ' + refusePassFlag + '" href="javascript:void(0)" onclick="refusePass(\'' + row.id + '\')"><i class="fa fa-close"></i>拒绝审核</a>  ');

                            // 审核通过
                            actions.push('<a class="btn btn-success btn-xs ' + adoptTxFlag + '" href="javascript:void(0)" onclick="adoptTx(\'' + row.id + '\')"><i class="fa fa-check"></i>审核通过</a> ');

                        } else if (row.status == 4) {
                            // 拒绝审核
                            // actions.push('<a class="btn btn-danger btn-xs ' + refusePassFlag + '" href="javascript:void(0)" onclick="refusePass(\'' + row.id + '\')"><i class="fa fa-close"></i>拒绝审核</a>  ');

                            // 审核通过
                            // actions.push('<a class="btn btn-success btn-xs ' + adoptTxFlag + '" href="javascript:void(0)" onclick="adoptTx(\'' + row.id + '\')"><i class="fa fa-check"></i>重复发起</a> ');
                        }
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    // 拒绝审核
    function refusePass(id) {
        var url = prefix + "/refusePass/" + id;
        $.modal.open("拒绝审核", url, 800, 600);
    }

    // 申请通过
    function adoptTx(id) {
        var url = prefix + "/adoptTx/" + id;
        $.modal.open("申请通过", url, 800, 600);
    }

</script>
</body>
</html>